#include <stdio.h>
#include <string.h>

#include "Stack.h"

#define LINE_MAXLEN 4096

const char *func_names[] = {
	"Clear",
	"Push",
	"Pop",
	"Top",
	"IsEmpty"
};



int
main(void)
{
	struct Stack s;
	char line[LINE_MAXLEN];
	char *quit_cmd = "quit";
	int  key = 0;

	while (scanf("%s", line) == 1) {
		if (!strcmp(line, func_names[0])) {
			Clear(&s);
		} else if (!strcmp(line, func_names[1])) {
			if (scanf("%d", &key) != 1)
				printf("\tExpected int, aborting\n");
			else
				Push(&s, key);
		} else if (!strcmp(line, func_names[2]))
			printf(" %d\n", Pop(&s));
		else if (!strcmp(line, func_names[3]))
			printf(" %d\n", Top(&s));
		else if (!strcmp(line, func_names[4]))
			printf(" %s\n", IsEmpty(&s) ? "Yes, stack is empty" : "No, stack aint empty");
		else if (!strcmp(line, quit_cmd))
			return 0;
		else
			printf("\tWrong function name\n");
	}
	fprintf(stderr, "Bye bye\n");
	return 0;
}
